package com.apexwear.apexutils.ui;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.apex.bluetooth.core.EABleBluetoothOption;
import com.apexwear.apexutils.R;
import com.apexwear.apexutils.adapter.AdapterTestList;
import com.apexwear.apexutils.databinding.ActivityTestDataBinding;

public class TestDataActivity extends AppCompatActivity {
    ActivityTestDataBinding dataBinding;
    AdapterTestList adapterTestList;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_test_data);
        dataBinding.tooBar.setNavigationIcon(R.mipmap.exit_page);
        setSupportActionBar(dataBinding.tooBar);
        getSupportActionBar().setTitle(null);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(RecyclerView.VERTICAL);
        dataBinding.tooBar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        String[] testPages = getResources().getStringArray(R.array.test_page);
        adapterTestList = new AdapterTestList(testPages, TestDataActivity.this);
        dataBinding.functionList.setLayoutManager(linearLayoutManager);
        dataBinding.functionList.setAdapter(adapterTestList);

    }

    @Override
    protected void onDestroy() {
        dataBinding.functionList.setLayoutManager(null);
        dataBinding.functionList.setAdapter(null);
        dataBinding.functionList.clearAnimation();
        dataBinding.functionList.removeAllViews();
        if (adapterTestList != null) {
            adapterTestList.destroyAdapter();
            adapterTestList = null;
        }
        if (dataBinding != null) {
            dataBinding.unbind();
            dataBinding = null;
        }
        super.onDestroy();
    }
}
